<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

<ui:composition template="/restrito/principal.xhtml">
<ui:define name="titulo">
   	Cadastro de Serviços
</ui:define>
<ui:define name="corpo">
<h:form id="listagem">   
<p:dataTable id="datatable" var="servico" value="#{servicoBean.lista}"  
	sortBy="#{servico.cod_servic}" sortOrder="DESCENDING" 	
	widgetVar="servicoTable" style="width:795px; margin-left:-10px;" paginator="true"
	paginatorPosition="bottom" rows="10" emptyMessage="Nenhum serviço encontrado!" 
	rowsPerPageTemplate="5,10,15" filteredValue="#{servicoBean.pesquisarServico}">	 
	<f:facet name="header">
		<p:commandButton value="Novo Serviço" action="#{servicoBean.novo}" />
		<h:outputText value="Pesquisar Serviço: " style="margin-left:280px;"/>  
		<p:inputText id="globalFilter" onkeyup="servicoTable.filter()" style="width:200px" filterPosition="left"/> 
	</f:facet>
	<p:column id="colunaCodigo" filterBy="#{servico.cod_servic}" sortBy="#{servico.cod_servic}"  filterStyle="display:none"  style="width:15px; text-align:center;"> 
		<f:facet name="header">
			<h:outputText value="Codigo"/> 
		</f:facet> 
		<h:outputText value="#{servico.cod_servic}" id="codigo"/>  
	</p:column> 
		           		
	<p:column id="colunaDescricao" filterBy="#{servico.des_servic}" filterStyle="display:none" style="width:70px; text-align:center;" > 
		<f:facet name="header">
			<h:outputText value="Descrição Serviço"/> 
		</f:facet> 
		<h:outputText value="#{servico.des_servic}" id="descricao"/>  
	</p:column> 
		           		
	<p:column id="colunaExcluir" style="width:10px; text-align:center;"> 
		<f:facet name="header"> 
			<h:outputText value="Excluir" id="excluir"/> 
		</f:facet>
		<p:commandLink action="#{servicoBean.excluir}" onclick="if (!confirm('Confirma a exclusão da #{servico.des_servic}?')) return false;" update="datatable">
			<h:graphicImage library="imagens" name="excluir16.png" style="border:0;"/>
			<f:setPropertyActionListener target="#{servicoBean.servico}" value="#{servico}"/>
		</p:commandLink>
	</p:column>

	<p:column id="colunaAlterar" style="width:10px; text-align:center;"> 
		<f:facet name="header"> 
			<h:outputText value="Alterar" id="alterar"/> 
		</f:facet>
		<p:commandLink action="#{servicoBean.alterar}" update="datatable">
			<h:graphicImage library="imagens" name="editar16.png" style="border:0;"/>
			<f:setPropertyActionListener target="#{servicoBean.servico}" value="#{servico}"/>
		</p:commandLink>
	</p:column>			           		 
</p:dataTable>
</h:form>	
</ui:define>
</ui:composition> 
</html>
